<template>
	<view class="page">

		<image class="head-image" mode="aspectFill" :src="detail.icon"></image>

 

		<view class="content">
			<view><u--text mode="price" :text="detail.price" type="error" :bold="true"></u--text></view>
			<view class="title">{{detail.title}}</view>
 

<!-- 			<u-cell-group :border="false">
				<u-cell :border="false" icon="clock-fill" 
				iconStyle="font-size: 52rpx;color:#003a86;" 
				title="日期"
					:label="detail.starttime + '-' + detail.endtime" center>
					</u-cell>
					 -->
 
		 
		 

	<u-cell :border="false"  
					:label="detail.provider" center>
					<view slot="title" class="u-slot-title">
						<text>数量:{{detail.amount}}</text>
					</view>
				</u-cell>
				
 
				
				
				<u-cell :border="false" 
					:label="detail.provider" center>
					<view slot="title" class="u-slot-title">
						<text>{{detail.introduce}}</text>
					</view>
				</u-cell>

		 
			</u-cell-group>
		</view>

		<view style="margin: 40rpx 20rpx;" v-if="detail.location">
			<map style="width: 100%; height: 500rpx;" :latitude="covers[0].latitude" :longitude="covers[0].longitude"
				:markers="covers"></map>
		</view>

		<view class="detail">
			<view class="name">产品详情</view>
			<view>
				
				<image class="head-image" mode="aspectFill" :src="detail.image1"></image>
				
				<!-- <u-parse :content="detail.image1"></u-parse> -->
			</view>
		</view>

 
 


		<view class="joinbutton" @tap="join">
			<!-- <u-button customStyle="join_btn"  class="join_btn" text="立刻购买"></u-button> -->
			<view  class="join_btn" >立刻购买</view>
		</view>
		
		
		
		
		
		
		

	</view>
</template>

<script>
	import * as mod_detail_default from '@/pages/activity/controller/model/mod_detail_default.js'
	import MxBuyButton from '@/components/common/MxBuyButton.vue';
	import * as Config from '@/utils/config.js';
	import * as product_api from '@/api/product.js'
	import * as UserApi from '@/api/user.js'
	import * as SettingApi from '@/api/setting.js'
	import {
		wxPayment
	} from '@/utils/app'
	export default {
		components: {
			MxBuyButton
		},
		data() {
			return {
				isLogin: false,
				src: 'https://youqu.arrow.enpingshi.com/uploadfiles/logo.jpg',
				detail: {},
				id: 0,
				coupon_price: 0,
				is_in_group: "",
				is_in_h5: "",
				h5_apply_info:"",
				covers: [{
					id: 1,
					latitude: 23.127289,
					longitude: 113.115628,
					member_group_tag: [],
					width: 50,
					height: 50,
					iconPath: '/static/location.png',
					callout: {
						// color: '#007AFF', // 文本颜色
						bgColor: '#fff', // 背景色
						display: "ALWAYS", // 'BYCLICK':点击显示; 'ALWAYS':常显
						fontSize: 14,
						padding: 10, // 文本边缘留白
						borderRadius: 5,
						content: '',
					},
					urlParam: null,
					customStyle: {
						width: '100px',
					}
				}],
			}
		},
		onLoad(e) {
			this.id = e.id
			console.log("catch the post data ",this.id)
			//分享进来的
			if (e.type && e.type == 'share') {
				uni.setStorageSync('share_order_param', e)
			}
 

		},
		onShow() {
			console.log('返回页面触发');
			 

			if (uni.getStorageSync('user_id')) {
				this.isLogin = true;
			}

			if (uni.getStorageSync('share_order_param')) {
				UserApi.get_share({
					order_id: uni.getStorageSync('share_order_param').order_id
				}).then(res => {
					uni.setStorageSync('share_order_param', '')
				})
			}

			this.getDetail()
		},
		/*分享当前页面*/
		onShareAppMessage(res) {

			if (res.from === 'button') { // 来自页面内分享按钮
				UserApi.share_event().then(res => {

				})
				return {
					title: '你的好友邀请你免费参加活动：' + this.detail.theme,
					path: '/pages/activity/detail?type=share&order_id=' +
						this.detail.order_detail.order_id +
						'&id=' + this.id +
						'&referee_id=' + uni.getStorageSync('user_id')
				};
			} else { 

			}

		},
		onShareTimeline() {
			return {
				title: this.detail.theme,
				imageUrl: this.detail.image1
			}
		},
		methods: {

	 
			 


			//获取当前用户信息
			get_member(usernid) {
				UserApi.UserInfo().then(res => {
					if (res.status == 200) {
						console.log("get_member 获取当前用户信息 res", res)
						this.now_member = res.data
					}
				})
			},

 


			//报名参加活动
			join() {
				
				console.log("走去确定订单")
				
				if (this.isLogin) {
					uni.navigateTo({
						url: '/pages/activity/pay?id=' + this.id
					})
				}
				else{
					//uni.setStorageSync('buy_goods_id', this.id)
					
					uni.navigateTo({
						url: "/pages/login/index"
					})
					
				}
				
				
/*
				if (this.isLogin) {
					UserApi.checkUserInfo().then(res => {
						if (res.status == 200) {
							// uni.navigateTo({
							// 	url: '/pages/activity/pay?id=' + this.id
							// });
							//传递event id sex user id  phone
							console.log("res", res)
							console.log("点击参与,应该递交参数过去")

							product_api.join({
								user_id: uni.getStorageSync('user_id'),
								event_id: this.id,
								// sex: this.coupon_id,//性别从后端获取吧
								// phone: this.member.phone,
							}).then(res => {
								if (res.status == 200) {
									console.log("product_api.join.res", res)
									//提示报名成功,并且删除报名按钮
									uni.$u.toast('报名成功。')
									this.detail.order_detail = 1
									this.getDetail()
								} else {
									console.log("product_api.join.res", res)
									this.$error(res.info)
								}


							})




						} else if (res.status == 601) {
							uni.showModal({
								title: '提示',
								content: res.info,
								success: function(res) {
									if (res.confirm) {
										uni.navigateTo({
											url: "/pages/user/set"
										})
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});

						}
					})
				} else {
					uni.navigateTo({
						url: "/pages/login/index"
					})
				}
				
				*/
			},


 
  

		toPhone(number) {
				uni.makePhoneCall({
									phoneNumber:number, //要拨打的手机号
									success: (res) => {console.log("调用成功")},
									fail: (res) => {console.log('调用失败!')}
								  })
						
						},
						
						

			getDetail() 
			{
				let that = this;
				product_api.detail
				({
					id: this.id
				}).then
				(res => {
					that.detail = res.info
					console.log("that.detail",that.detail)
  
				}) 
			},
					
					
					
					
					
				}
				}
</script>






<style scoped lang="scss">
	@import url("asset/detail.css");
</style>